/**
 * Created by Sunnie on 19/06/04.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  const valid_map = ['admin', 'editor']
  return valid_map.indexOf(str.trim()) >= 0
}

	//时间 --- 年/月/日
	export const formatDate = (date) => {
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var day = date.getDate();
		var hour = date.getHours();
		var minute = date.getMinutes();
		var second = date.getSeconds();
		return year + "-" + month + "-" + day
	}


	//时间 --- 年,月,日
	export const formatGetDate = (date) => {
		var year = date.getFullYear();
		var month = date.getMonth();
		var day = date.getDate();
		var hour = date.getHours();
		var minute = date.getMinutes();
		var second = date.getSeconds();
		return{
			year:year,
			month:month,
		day:day
		}
	}

	//时间 --- 月份天数
	export const formatDateDays = (date) => {
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var mm = new Date(year,month,0).getDate()
		return mm
	}


	//时间字符串拼接--- xxxx年xx月xx日
	export const formatDateSplicing = (date) => {
		var frontData = date.split(' ')[0]
		var completeData = frontData.split('-')[0]+'年'+frontData.split('-')[1]+'月'+frontData.split('-')[2]+'日'
		return completeData
	}